import React from 'react'
import { bus } from 'utils'

export function useBus(name, fn, deps = []) {
  React.useEffect(() => {
    bus.on(name, fn)
    return () => bus.off(name, fn)
  }, deps)
}
